#[derive(Debug)]
enum SpreadsheetCell {
    Int(i32),
    Float(f64),
    Text(String),
}

fn main() {
    let mut v = Vec::new(); // 新建空的可变vector

    v.push(5);  // 更新vector
    v.push(6);
    v.push(7);
    v.push(8);

    println!("vectot v[3] {}", &v[3]);

    for i in &mut v { // 遍历可变vector，并修改值
        *i += 50;
    }
    for i in &v { // 遍历vector，并打印
        println!("{}", i);
    }

    let v = vec![1, 2, 3, 4, 5]; // 新建并初始化

    let third: &i32 = &v[2]; // 读取元素
    println!("The third element is {}", third);

    match v.get(3) { // 读取元素，返回Option<&T>
        Some(fourth) => println!("The fourth element is {}", fourth),
        None => println!("There is no fourth element"),
    }

    let row = vec![ // 新建枚举类型的vector，可以放不同的类型
        SpreadsheetCell::Int(3),
        SpreadsheetCell::Text(String::from("blue")),
        SpreadsheetCell::Float(10.12),
    ];

    println!("{:#?}", &row[1]);
}
